//
//  HomeTableViewCell.m
//  GenericProject
//
//  Created by 皮蛋菌 on 2023/5/9.
//  Copyright © 2023 漠然丶情到深处. All rights reserved.
//

#import "HomeTableViewCell.h"

@interface HomeTableViewCell ()

@property(nonatomic,strong)UIImageView *videoImageView;
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UILabel *sizeLabel;

@end

@implementation HomeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    self.videoImageView = [[UIImageView alloc]init];
    self.videoImageView.layer.masksToBounds = YES;
    self.videoImageView.layer.cornerRadius = LSSYRealValue(4);
    self.videoImageView.backgroundColor = LSRedColor;
    [self.contentView addSubview:self.videoImageView];
    [self.videoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(LSSYRealValue(10));
        make.left.equalTo(self.contentView).with.offset(LSSYRealValue(16));
        make.size.mas_equalTo(CGSizeMake(LSSYRealValue(120), LSSYRealValue(80)));
    }];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textColor = [UIColor lsLigthColor:LSBlackColor darkColor:LSWhiteColor];
    self.titleLabel.font = LSSystemFont(LSSYRealValue(16));
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.videoImageView).with.offset(0);
        make.left.equalTo(self.videoImageView.mas_right).with.offset(LSSYRealValue(10));
        make.right.equalTo(self.contentView.mas_right).with.offset(LSSYRealValue(-30));
    }];
    
    self.sizeLabel = [[UILabel alloc]init];
    self.sizeLabel.textColor = [UIColor lsLigthColor:LSBlackColor darkColor:LSWhiteColor];
    self.sizeLabel.font = LSSystemFont(LSSYRealValue(12));
    [self.contentView addSubview:self.sizeLabel];
    [self.sizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.videoImageView.mas_bottom).with.offset(0);
        make.left.equalTo(self.videoImageView.mas_right).with.offset(LSSYRealValue(10));
        make.right.equalTo(self.contentView.mas_right).with.offset(LSSYRealValue(-30));
    }];
}

- (void)setVideoModel:(VideoModel *)videoModel {
    _videoModel = videoModel;
    
    self.titleLabel.text = videoModel.videoNameString;
    self.sizeLabel.text = videoModel.videoSizeString;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
